<?php
	require_once('client_config.php');
	require_once('ntml_soapclient.php');

	$client = new MyNTMLSoapClient('./ews/services.wsdl', $soap_options);
	$client->set_profile($user_profile['login'], $user_profile['password']);
	$appointments = $client->find_newest_appointments(5,&$errcode, &$error);
	if($errcode !== "NoError"){
		echo "Error: " . $errcode . "( " . $error ." )";
	}else{
		echo "<table border='1' align='center'>";
		echo "<CAPTION><font color='blue'><b>The five newest appointments</b></font></CAPTION>";

		echo "<thead><tr>\n";
		echo "<th>Subject</th>\n";
		echo "<th>Start date</th>\n";
		echo "<th>End date</th>\n";
		echo "<th>Detail</th>\n";
			echo "</tr></thead>\n";
		echo "<tbody>";
		foreach($appointments as $appointment){
			$redirect_link = "update_appointment.php";
			echo $appointment->display_as_row($redirect_link ,array(1,0,0,0,1,1,1));
		}
		echo "<tr><td colspan='2'></td><td colspan='2' align='center'><a href='add_appointment.php'>New Appointment</a></td></tr>";
		echo "</tbody></table>";
	}

	exit;
?>